//
//  QInvoiceManageVC.m
//  QoilPublic
//
//  Created by 杨凯 on 2017/2/16.
//  Copyright © 2017年 杨凯. All rights reserved.
//

#import "QInvoiceManageVC.h"
#import "QInvoiceManageCell.h"
#import "QInfoManageVC.h"
#import "QInvoiceRecordVC.h"
#import "QMakeInvoiceVC.h"
@interface QInvoiceManageVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView *tbView;
@end

@implementation QInvoiceManageVC

- (id)init{
    self = [super init];
    if (self) {
        
        self.hidesBottomBarWhenPushed = YES;
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"发票管理";
    [self createUI];
}
- (void)createUI{

    [self.view addSubview:self.tbView];
    [self.tbView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@8);
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    
    [self.tbView registerNib:[UINib nibWithNibName:@"QInvoiceManageCell" bundle:nil] forCellReuseIdentifier:@"QInvoiceManageCell"];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [[UIView alloc]init];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc] init];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    QInvoiceManageCell * cell= [tableView dequeueReusableCellWithIdentifier:@"QInvoiceManageCell" forIndexPath:indexPath];
    cell.indexPath = indexPath;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        //开票信息管理
        QInfoManageVC * vc =[[QInfoManageVC alloc]init];
        vc.state = @"";//获取所有开票信息 传空
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 1){
        //发票申请
        QMakeInvoiceVC * vc =[[QMakeInvoiceVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 2){
        //开票纪录
        QInvoiceRecordVC * vc =[[QInvoiceRecordVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (UITableView*)tbView {
    if (!_tbView) {
        _tbView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tbView.dataSource = self;
        _tbView.delegate = self;
        _tbView.backgroundColor = [UIColor clearColor];
        _tbView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tbView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
